<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <h3 class="panel-title">物料详情 - {$row.name}</h3>
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="120">物料名称</th>
                        <td>{$row.name}</td>
                    </tr>
                    <tr>
                        <th>物料编码</th>
                        <td>{$row.code}</td>
                    </tr>
                    <tr>
                        <th>物料分类</th>
                        <td>{$row.category}</td>
                    </tr>
                    <tr>
                        <th>规格型号</th>
                        <td>{$row.spec}</td>
                    </tr>
                    <tr>
                        <th>单位</th>
                        <td>{$row.unit}</td>
                    </tr>
                    <tr>
                        <th>颜色</th>
                        <td>{$row.color}</td>
                    </tr>
                    <tr>
                        <th>材质</th>
                        <td>{$row.material_type}</td>
                    </tr>
                    <tr>
                        <th>品牌</th>
                        <td>{$row.brand}</td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="120">默认供应商</th>
                        <td>{$row.default_supplier.name|default='未设置'}</td>
                    </tr>
                    <tr>
                        <th>当前参考价</th>
                        <td>¥{$row.current_price}</td>
                    </tr>
                    <tr>
                        <th>当前库存</th>
                        <td>{$row.stock} {$row.unit}</td>
                    </tr>
                    <tr>
                        <th>最低库存预警</th>
                        <td>{$row.min_stock} {$row.unit}</td>
                    </tr>
                    <tr>
                        <th>最高库存</th>
                        <td>{$row.max_stock} {$row.unit}</td>
                    </tr>
                    <tr>
                        <th>安全库存</th>
                        <td>{$row.safety_stock} {$row.unit}</td>
                    </tr>
                    <tr>
                        <th>采购提前期</th>
                        <td>{$row.lead_time} 天</td>
                    </tr>
                    <tr>
                        <th>库存状态</th>
                        <td>{$row.stock_status_text}</td>
                    </tr>
                </table>
            </div>
        </div>
        
        {if condition="$row.description"}
        <div class="row">
            <div class="col-md-12">
                <h4>描述信息</h4>
                <p class="text-muted">{$row.description}</p>
            </div>
        </div>
        {/if}
        
        <div class="row">
            <div class="col-md-6">
                <h4>供应商报价对比</h4>
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>供应商</th>
                            <th>报价</th>
                            <th>起订量</th>
                            <th>交货期</th>
                            <th>优先</th>
                            <th>评分</th>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach name="suppliers" item="vo"}
                        <tr {if condition="$vo.is_preferred eq 1"}class="success"{/if}>
                            <td>{$vo.supplier.name}</td>
                            <td>¥{$vo.price}</td>
                            <td>{$vo.min_order_qty}</td>
                            <td>{$vo.delivery_days}天</td>
                            <td>{if condition="$vo.is_preferred eq 1"}<span class="label label-success">是</span>{else}<span class="label label-default">否</span>{/if}</td>
                            <td>
                                <span class="text-warning">
                                    {for start="1" end="$vo.quality_rating"}
                                    <i class="fa fa-star"></i>
                                    {/for}
                                </span>
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
            <div class="col-md-6">
                <h4>使用该物料的工序</h4>
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>产品型号</th>
                            <th>工序</th>
                            <th>用量</th>
                            <th>损耗率</th>
                            <th>必需</th>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach name="processes" item="vo"}
                        <tr>
                            <td>{$vo.model.product.name} - {$vo.model.name}</td>
                            <td>{$vo.process.name}</td>
                            <td>{$vo.quantity}</td>
                            <td>{$vo.loss_rate}%</td>
                            <td>{if condition="$vo.is_required eq 1"}<span class="label label-danger">必需</span>{else}<span class="label label-default">可选</span>{/if}</td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="row">
            <div class="col-md-12">
                <h4>最近采购记录</h4>
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>采购单号</th>
                            <th>供应商</th>
                            <th>数量</th>
                            <th>单价</th>
                            <th>金额</th>
                            <th>采购日期</th>
                            <th>到货状态</th>
                        </tr>
                    </thead>
                    <tbody>
                        {foreach name="purchases" item="vo"}
                        <tr>
                            <td>{$vo.purchase_no}</td>
                            <td>{$vo.supplier.name}</td>
                            <td>{$vo.quantity}</td>
                            <td>¥{$vo.unit_price}</td>
                            <td>¥{$vo.total_amount}</td>
                            <td>{$vo.purchase_date|date='Y-m-d'}</td>
                            <td>{$vo.arrival_status_text}</td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
